

********************************************************************************
********************************************************************************
* This Do File, replicates every Non-Summary Table in the Main Article
********************************************************************************
********************************************************************************



********************************************************************************
********************************************************************************
* Setup
********************************************************************************
********************************************************************************
include Fixed_Effects.do


********************************************************************************
********************************************************************************
* Table 3: Determinants of Bank Exit Policy Adoption and Strength
********************************************************************************
********************************************************************************
use "../Intermediate/policy_determinants_panel", clear 
keep if sample_big & share_gcel_pre_agg <= 1

eststo clear

reghdfe ban_intensity_2030  loglending_pre_agg, ///
    noabs vce(robust)
eststo

reghdfe ban_intensity_2030  loglending_pre_agg share_gcel_pre_agg, ///
    noabs vce(robust)
eststo

reghdfe ban_intensity_2030  loglending_pre_agg share_gcel_pre_agg   ///
    _b_bank_year_0913 _b_firm_year_0913 , ///
    noabs vce(robust)
eststo

reghdfe ban_intensity_2030  loglending_pre_agg share_gcel_pre_agg  ///
    _b_bank_year_0913 _b_firm_year_0913 indus_esg_2020 enviro_esg_2020, ///
    noabs vce(robust)
eststo

reghdfe ban_intensity_2030  loglending_pre_agg share_gcel_pre_agg  ///
    _b_bank_year_0913 _b_firm_year_0913 indus_esg_2020 enviro_esg_2020 ib4.nContinent, ///
    noabs vce(robust)
eststo


esttab, stats(r2 N) nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers label  nomtitles drop(4.nContinent)
esttab using "../Results/Tables/Table_3.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                r2 nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers label interaction(" $\times$ ") drop(4.nContinent) nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule"  ///
                                                              "& \multicolumn{5}{c}{Policy Existence and Strength}\\" ///
                                                              "\cmidrule(r{2pt}){2-6}") 

															  
********************************************************************************
********************************************************************************
* Table 4: Bank Financing of Coal Activity
********************************************************************************
********************************************************************************
use "../Intermediate/bank_financing_regressions", clear
keep if has_coded_policy==1 & year>=2006

eststo clear

reghdfe log_lend active_policy, ///
    absorb(year BankID) vce(robust)
FE1
eststo

reghdfe log_lend active_policy c.post15#c.ban_intensity_new1_max_sd, ///
    absorb(year BankID) vce(robust)
FE1
eststo

reghdfe log_lend active_policy c.post15#c.rf_score_sd, ///
    absorb(year BankID) vce(robust)
FE1
eststo

reghdfe log_lend active_policy c.post15#c.rf_phaseout_score_sd, ///
    absorb(year BankID) vce(robust)
FE1
eststo

reghdfe log_lend active_policy c.post15#c.complexity_score_max_sd, ///
    absorb(year BankID) vce(robust)
FE1
eststo

reghdfe log_lend active_policy_initial c.post15#c.ban_intensity_initial_max_sd, ///
    absorb(year BankID) vce(robust)
FE1
eststo

esttab, label starlevels(* .10 ** .05 *** .01) se(%8.3f) ///
    order(active_policy active_policy_initial)

esttab using "../Results/Tables/Table_4.tex", replace booktabs b(%8.3f) se(%8.3f)  order(active_policy active_policy_initial) ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label substitute("\_" "_") interaction(" $\times$ ") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "& \multicolumn{6}{c}{Coal Debt Origination (log)} \\" ///
                                                              "\cmidrule{2-7}") ///
                stats(bank cy N r2_a , fmt( 0 0 %8.0fc 3) labels("Bank FE" "Year FE" "Observations" "Adj-R$^2$" ))

********************************************************************************
********************************************************************************
* Table 5: Bank Exit Policies Effects: Isolating the Supply Channel
********************************************************************************
********************************************************************************
use "../Intermediate/bank_supply_chain_regressions", clear

eststo clear

reghdfe log_1p_borr_fbt ban_intensity_new1, absorb(borrower_id#year BankID) cluster(BankID borrower_id)
FE1
eststo
	
reghdfe log_1p_borr_fbt i.highshare#c.ban_intensity_new1, absorb(borrower_id#year BankID) cluster(BankID borrower_id)
FE1
eststo

reghdfe log_1p_borr_fbt i.median_assets_mean#c.ban_intensity_new1, absorb(borrower_id#year BankID) cluster(BankID borrower_id)
FE1
eststo

reghdfe log_1p_borr_fbt c.ban_intensity_new1 if coal_industry_mining == 0, absorb(borrower_id#year BankID) cluster(BankID borrower_id)
FE1
eststo

reghdfe log_1p_borr_fbt c.ban_intensity_new1 if coal_industry_mining == 1, absorb(borrower_id#year BankID) cluster(BankID borrower_id)
FE1
eststo

esttab, label numbers starlevels(* .10 ** .05 *** .01) b(%8.3f) se(%8.3f)  nocons stats(N r2_a)

esttab using "../Results/Tables/Table_5.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label substitute("\_" "_") interaction(" $\times$ ") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "& \multicolumn{5}{c}{Debt Issuance (log)} \\" ///
                                                              "\cmidrule{2-6}" ///
															  "& & & & Power & Mining \\" ///
															  "\cmidrule{5-6}") ///
                stats(bank borrower_year N r2_a , fmt( 0 0 %8.0fc 3) labels("Bank FE" "Borrower x Year FE" "Observations" "Adj-R$^2$" )) ///
				postfoot("\bottomrule \\ \end{tabular}}")
				
********************************************************************************
********************************************************************************
* Table 6: Effects of Bank Exit on Coal Firm Debt Issuance
********************************************************************************
********************************************************************************
use ../Intermediate/analysis_panel_firmyear, clear
keep if aggborr_pre_debt > 0 & Country != "xChina"

eststo clear

reghdfe log_debt ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year) cl(borrower_id)
FE4
eststo

reghdfe log_debt ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_debt c.ss_pre_all_debt_banintsty_n1_sd#i.highshare, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_debt c.ss_pre_all_debt_banintsty_n1_sd#i.median_assets_mean, ///
    absorb(borrower_id i.count#i.year i.year) cl(borrower_id)
FE3nosy
eststo

reghdfe log_debt ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==0, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_debt ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==1, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo


esttab, label nonumbers nocons starlevels(* .10 ** .05 *** .01) 

esttab using "../Results/Tables/Table_6.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label substitute("\_" "_") interaction(" $\times$ ") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "& \multicolumn{6}{c}{Debt Issuance (log)} \\" ///
                                                              "\cmidrule{2-7}" ///
                                                              "& & & & & Power & Mining \\"  /// 
                                                              "\cmidrule(r{2pt}){6-7} ") ///
                stats(borrower y cy sy N r2_a , fmt(0 0 0 0 %8.0fc 3) labels("Borrower FE" "Year FE" "Country x Year FE" "Size x Year FE" "Observations" "Adj-R$^2$" ))
********************************************************************************
********************************************************************************
* Table 7: Adjustment Margin and Substitutions Channels
********************************************************************************
********************************************************************************
use ../Intermediate/analysis_panel_firmyear, clear
keep if aggborr_pre_debt>0 & Country!="xChina"

eststo clear

reghdfe log_debt_has_coded_policy c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe log_debt_nopol c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe log_debt_rel_all_pre c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe log_debt_norel_all_pre c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe log_debt_non_bank c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe log_debt_banks c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe pos_debt c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe logim_debt c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

reghdfe log_equity_public c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE2
eststo

esttab, label nocons nonotes starlevels(* .10 ** .05 *** .01) ///
    nolegend nonumber interaction(" $\times$ ") ///
    mgroups(A B C D, pattern(1 0 1 0 1 0 1 ))

esttab using "../Results/Tables/Table_7.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend nonumbers ///
                label substitute("\_" "_") interaction(" $\times$ ") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabularx}{1.35\textwidth}{Xl*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "& \multicolumn{8}{c}{Debt Issuance (log)} & Equity \\" ///
                                                              "\cmidrule{2-10}" ///
                                                              "& \multicolumn{2}{c}{Coal Policy Bank} & \multicolumn{2}{c}{Relationship Bank}  & \multicolumn{2}{c}{Non-Bank} &                                 \multicolumn{2}{c}{Margin} \\" ///
                                                              "\cmidrule(r{2pt}){2-3}  \cmidrule(l{2pt}){4-5} \cmidrule(l{2pt}){6-7} \cmidrule(l{2pt}){8-9} " ///
                                                              "& Yes & No & Yes & No & Yes & No & Extensive & Intensive & \\")  ///
                                postfoot("\bottomrule \end{tabularx}}") ///
                stats(borrower cy sy N r2_a , fmt( 0 0 0 %8.0fc 3) labels("Borrower FE" "Country x Year FE" "Size x Year FE" "Observations" "Adj-R$^2$" ))

********************************************************************************
********************************************************************************
* Table 8: Balance Sheet Effects
********************************************************************************
********************************************************************************
use ../Intermediate/analysis_panel_firmyear, clear
keep if Country!="xChina"

***Panel A: Long Term Debt 
eststo clear

reghdfe log_ltd ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year) cl(borrower_id)
FE4
eststo

reghdfe log_ltd ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_ltd i.highshare#c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_ltd c.ss_pre_all_debt_banintsty_n1_sd#i.median_assets_mean, ///
    absorb(borrower_id i.count#i.year i.year) cl(borrower_id)
FE3nosy
eststo

reghdfe log_ltd ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==0, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_ltd ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==1, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

esttab, label starlevels(* .10 ** .05 *** .01) nocons

esttab using "../Results/Tables/Table_8_Panel_A.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label interaction(" $\times$ ") ///
				substitute("\_" "_") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "&  \multicolumn{6}{c}{\textbf{Long-Term Debt (log)}}  \\" ///
															  "\cmidrule{2-7} & & & & & Power & Mining \\" ///
                                                              "\cmidrule(l{2pt}){6-7}") ///
                stats(borrower y cy sy N r2_a , fmt(0 0 0 0 %8.0fc 3) labels("Borrower FE" "Year FE" "Country x Year FE" "Size x Year FE" "Observations" "Adj-R$^2$" ))
              

***Panel B: Leverage  
eststo clear

reghdfe log_lev ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year) cl(borrower_id)
FE4
eststo

reghdfe log_lev ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_lev i.highshare#c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_lev c.ss_pre_all_debt_banintsty_n1_sd#i.median_assets_mean, ///
    absorb(borrower_id i.count#i.year i.year) cl(borrower_id)
FE3nosy
eststo

reghdfe log_lev ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==0, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_lev ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==1, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

esttab, label starlevels(* .10 ** .05 *** .01) nocons

esttab using "../Results/Tables/Table_8_Panel_B.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label interaction(" $\times$ ") ///
				substitute("\_" "_") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "&  \multicolumn{6}{c}{\textbf{Leverage (log)}}  \\" ///
															  "\cmidrule{2-7} & & & & & Power & Mining \\" ///
                                                              "\cmidrule(l{2pt}){6-7}") ///
                stats(borrower y cy sy N r2_a , fmt(0 0 0 0 %8.0fc 3) labels("Borrower FE" "Year FE" "Country x Year FE" "Size x Year FE" "Observations" "Adj-R$^2$" ))
	
***Panel C: Total Assets  
eststo clear

reghdfe log_size ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year) cl(borrower_id)
FE4
eststo

reghdfe log_size ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_size i.highshare#c.ss_pre_all_debt_banintsty_n1_sd, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_size c.ss_pre_all_debt_banintsty_n1_sd#i.median_assets_mean, ///
    absorb(borrower_id i.count#i.year i.year) cl(borrower_id)
FE3nosy
eststo

reghdfe log_size ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==0, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

reghdfe log_size ss_pre_all_debt_banintsty_n1_sd if coal_industry_mining==1, ///
    absorb(borrower_id year i.count#i.year quintile_assets#i.year) ///
    cl(borrower_id)
FE3
eststo

esttab, label starlevels(* .10 ** .05 *** .01) nocons

esttab using "../Results/Tables/Table_8_Panel_C.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label interaction(" $\times$ ") ///
				substitute("\_" "_") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "&  \multicolumn{6}{c}{\textbf{Total Assets (log)}}  \\" ///
															  "\cmidrule{2-7} & & & & & Power & Mining \\" ///
                                                              "\cmidrule(l{2pt}){6-7}") ///
                stats(borrower y cy sy N r2_a , fmt(0 0 0 0 %8.0fc 3) labels("Borrower FE" "Year FE" "Country x Year FE" "Size x Year FE" "Observations" "Adj-R$^2$" ))
				
********************************************************************************
********************************************************************************
* Table 9: Facility Level Effects
********************************************************************************
********************************************************************************
//Panel A: Effects on Coal-fired Power Plant Closures
use ../Intermediate/plant_year_panel_clean, clear

*Setting up Cox Model
stset year, failure(retired) id(plant_parent_id) origin(first_date_Operating_year) 
local clvar Country

eststo clear

stcox ban_intensity_max_sd if year < 2015, strata(Country) vce(cl ParentID_GCEL)
FE_cy 
eststo 

stcox c.post2015##c.ban_intensity_max_sd, strata(country_i) vce(cl ParentID_GCEL) nohr
FE_cy 
eststo 

stcox c.post2015##c.ban_intensity_max_sd##c.small_firm, strata(Country) vce(cl ParentID_GCEL) 
FE_cy 
eststo 

stcox c.post2015##c.ban_intensity_max_sd##c.share_low, strata(Country)  vce(cl ParentID_GCEL) 
FE_cy 
eststo 

stcox c.post2015##c.ban_intensity_max_sd##c.big_plant, strata(Country)  vce(cl ParentID_GCEL) 
FE_cy 
eststo 

esttab, starlevels(* .10 ** .05 *** .01) eform t(%8.3f) label drop(c.ban_intensity_max_sd#c.small_firm c.ban_intensity_max_sd#c.share_low c.ban_intensity_max_sd#c.big_plant post2015 big_plant small_firm c.post2015#c.big_plant c.post2015#c.small_firm  c.post2015#c.share_low share_low) interaction(" $\times$ ")


esttab using "../Results/Tables/Table_9_Panel_A.tex", replace booktabs b(%8.3f) t(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                eform label substitute("\_" "_") interaction(" $\times$ ") ///
                drop(c.ban_intensity_max_sd#c.small_firm c.ban_intensity_max_sd#c.share_low c.ban_intensity_max_sd#c.big_plant post2015 big_plant small_firm c.post2015#c.big_plant c.post2015#c.small_firm  c.post2015#c.share_low share_low) ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{@M}{r}}" ///
                                                              "\toprule" ///
                                                              "& \multicolumn{5}{c}{Plant Closure} \\" ///
                                                              "\cmidrule{2-6}" ///
                                                              "& \multicolumn{1}{c}{Pre-Period} & \multicolumn{4}{c}{Full Sample} \\" ///
                                                              "\cmidrule(l{2pt}){2-2} \cmidrule(l{2pt}){3-6}") ///
                stats(country N, fmt( 0 0 %8.0fc) labels("Country Strata" "Observations"))
		
//Panel B: Effects on Coal-fired Power Plant CO2 Emissions
use "../Intermediate/Coal_Plant_Emissions", clear
eststo clear
       
reghdfe co2_scaled treatment_2015, absorb(newid i.count#i.year ) cl(year newid )  
FE1
eststo

reghdfe co2_scaled  treatment_2015 if active == 1, absorb(newid i.count#i.year ) cl(year newid )
FE1
eststo

reghdfe active treatment_2015, absorb(newid i.count#i.year ) cl(newid)
FE1
eststo

reghdfe co2_intensity_win treatment_2015, absorb(newid i.count#i.year ) cl(newid year) 
FE1
eststo


esttab, label starlevels(* .10 ** .05 *** .01) nocons

esttab using "../Results/Tables/Table_9_Panel_B.tex", replace booktabs b(%8.3f) se(%8.3f)  ///
                nocons nonotes starlevels(* .10 ** .05 *** .01) nolegend numbers ///
                label interaction(" $\times$ ") substitute("\_" "_") ///
                nomtitles prehead("{ \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}" ///
                                                              "\begin{tabular}{l*{4}{r}}" ///
                                                              "\toprule" ///
                                                              "& \multicolumn{1}{c}{Emissions} & \multicolumn{1}{c}{Active Facilities Only} & \multicolumn{1}{c}{Active (1/0)} & \multicolumn{1}{c}{Carbon Intensity}\\" ///
                                                              "\cmidrule{2-5}" ) ///
                stats(borrower cy N r2_a , fmt( 0 0 %8.0fc 3) labels("Facility FE" "Country x Year FE" "Observations" "Adj-R$^2$" ))

